package com.ssmtest.test.Service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ssmtest.test.Dao.UserDao;
import com.ssmtest.test.Pojo.User;
import com.ssmtest.test.Service.UserService;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UserServiceImpl extends ServiceImpl<UserDao,User>implements UserService {
    @Autowired
    private  UserDao userDao;
    @Override
    public IPage<User> getPage(int currentpage, int pageSize,User user) {
        LambdaQueryWrapper<User> lqw=new LambdaQueryWrapper<User>();
        lqw.like(Strings.isNotEmpty(user.getId()),User::getId,user.getId());  //模糊查询
        lqw.like(Strings.isNotEmpty(user.getName()),User::getName,user.getName());
        lqw.like(Strings.isNotEmpty(user.getAge()),User::getAge,user.getAge());
        lqw.like(Strings.isNotEmpty(user.getEmail()),User::getEmail,user.getEmail());
        IPage page=new Page(currentpage,pageSize);
        userDao.selectPage(page,lqw);
        return  page;
    }
}
